
<%@ include file="/WEB-INF/jsp/include/page_header.jspf" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">


<head>       

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.lightbox-0.5.js"></script>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/jquery.lightbox-0.5.css" media="screen" />
    <script src="${pageContext.request.contextPath}/js/jquery.form.js" type="text/javascript"></script>
    <script type="text/javascript">                     
                       
        function test(f) {
            $(f).clearForm();
        }
        
        function check(f) {
                
            if(document.form1.idPengguna.value.length == 0){
                alert("Sila masukkan ID Pengguna");
                form1.idPengguna.focus();
                return (false);
            } 
            if(document.form1.nama.value.length == 0){
                alert("Sila masukkan Nama");
                form1.nama.focus();
                return (false);
            } 
            str1 = f.password.value;
            str2 = f.repassword.value;
            if(document.form1.password.value.length == 0){
                alert("Sila masukkan Kata Laluan");
                form1.password.focus();
                return (false);
            }
            if (str1.length < 6) {
                alert("Kata Laluan tidak boleh kurang dari 6 aksara!!");
                return false;
            }
            if (str1.length > 10) {
                alert("Kata Laluan tidak boleh lebih dari 10 aksara!!");
                return false;
            }
            if (str1 != str2) {
                alert("Kata Laluan dan Pengesahan Kata Laluan tidak sama!!");
                return false;
            }
            return confirm("Click on OK to confirm");
        }        
                       
        function removePguna (val) {
            form = document.form1;
            var answer = confirm("adakah anda pasti untuk Hapus?");
            if (answer) {
                form.action = '${pageContext.request.contextPath}/uam_register?deletePguna&idPengguna='+val;
                form.submit();
            }
        }
            
           
        function jana(){
            $.post('${pageContext.request.contextPath}/uam_register?janaPassword',
            function(data){
                if(data != ''){
                    $('#password').val(data);
                    $('#repassword').val(data);
                }
            }, 'html');

        }
            
        function popup(url)
        {
            params  = 'width='+screen.width;
            params += ', height='+screen.height;
            params += ', top=0, left=0'
            params += ', fullscreen=yes';
            params += ', directories=no';
            params += ', location=no';
            params += ', menubar=no';
            params += ', resizable=no';
            params += ', scrollbars=yes';
            params += ', status=no';
            params += ', toolbar=no';
            newwin=window.open(url,'PopUp', params);
            if (window.focus) {newwin.focus()}
            return false;
        }
       
            
    </script>
</head>
<s:useActionBean beanclass="ipfms.stripes.util.ListUtil" var="list"/>
<s:form beanclass="ipfms.stripes.action.RegisterUserActionBean" name="form1">
    <s:messages />
    <s:errors />
    <div class="subtitle" >        
        <p></p>
        <legend>REGISTRATION USER</legend>
        <table width="100%" border="0" cellpadding="1" cellspacing="0" class="normaltext" bgcolor="#eee">               
            <td>&nbsp;</td>
            <tr><td  style="text-align: right"><font color="red">*</font> User ID :</td>
                <td>
                    <s:text name="p.idPengguna" style="width:250px" class="normal_text"/>
                </td></tr>
            <tr><td  style="text-align: right"><font color="red">*</font> Name :</td>
                <td>
                    <s:text name="p.nama" style="width:250px" class="normal_text"/>
                </td></tr>
            <tr><td  style="text-align: right"><font color="red">*</font> Password :</td>
                <td>
                    <s:text name="p.password" maxlength="10"  id="password" class="normal_text"/>    <s:button  name="save" class="btn" value="Generate" onclick="jana();" />
                </td></tr>
            <tr><td  style="text-align: right"><font color="red">*</font> Re-Password :</td>
                <td>
                    <s:text  name="pKataLaluan" maxlength="10"  id="repassword" class="normal_text"/>
                </td></tr>
            <tr><td  style="text-align: right"><font color="red">*</font>User Type :</td>
                <td class="s">
                    <s:select name="p.kodJenisPengguna.code">           
                        <s:option value="">Choose One</s:option>
                        <s:options-collection collection="${list.senaraiJenisPengguna}" label="desc" value="code"/>
                    </s:select>                                               
                </td></tr>
            <tr><td  style="text-align: right">Email :</td>
                <td class="s">
                    <s:text name="p.email" style="width:250px"  class="normal_text"/>                                           
                </td></tr>
            <tr><td  style="text-align: right"><font color="red">*</font> Phone No :</td>
                <td>
                    <s:text name="p.phone" style="width:250px" id="telefon" class="normal_text"/>
                </td></tr>
            <tr><td  style="text-align: right"><font color="red">*</font> Address :</td>
                <td>
                    <s:text name="p.add1"  style="width:250px"/>
                </td></tr>
            <tr><td  style="text-align: right"> &nbsp;</td>
                <td>
                    <s:text name="p.add2" style="width:250px"/>
                </td></tr>
            <tr><td  style="text-align: right"> &nbsp;</td>
                <td>
                    <s:text name="p.add3" style="width:250px"/>
                </td></tr>
            <tr><td  style="text-align: right"> &nbsp;</td>
                <td>
                    <s:text name="p.add4" style="width:250px"/>
                </td></tr>
            <tr><td  style="text-align: right"><font color="red">*</font> Poscode :</td>
                <td class="s">
                    <s:text name="p.poscode" id="poskod" size="5"/>
                </td></tr>
            <tr>
                <td style="text-align: right"><font color="red">*</font>State</td>
                <td class="s">
                    <s:select name="p.state.code">             
                        <s:option value="">Choose One</s:option>
                        <s:options-collection collection="${list.senaraiNegeri}" label="desc" value="code"/>
                    </s:select>                                               
                </td>
            </tr>
            <tr><td colspan="2">
                    <div align="center">
                        <s:submit  name="savePguna" value="Save" class="btn" onclick="check(this.form);"/>
                        <s:submit name="showForm" value="Clear" class="btn" onclick="test(this.form);"/>
                    </div>
                </td></tr>
        </table>
    </div>
    <br>

    <legend>LIST OF USER</legend>
    <div class="content" align="center">
        <display:table class="tablecloth" style="width:100%; border:0px;  bordercolor:#BBB;" name="${actionBean.senaraiPguna}" pagesize="10"
                       cellpadding="0" cellspacing="0" id="line"
                       requestURI="/uam_register">
            <display:column title="No" sortable="true" style="vertical-align:baseline">${line_rowNum}</display:column>
            <display:column property="idPengguna" title="User ID" style="vertical-align:baseline"/>
            <display:column title="Name">
                <input type='hidden' name="" id="nama_${line_rowNum-1}" value="${line.nama}"/>
                ${line.nama}
            </display:column>
            <display:column title="User Type">
                <input type='hidden' name="" id="kodPguna_${line_rowNum-1}" value="${line.kodJenisPengguna.code}"/>
                ${line.kodJenisPengguna.desc}
            </display:column>
            <display:column title="Active">
                <input type='hidden' name="" id="aktif_${line_rowNum-1}" value="${line.active}"/>
                ${line.active}
            </display:column>
            <display:column title="Add Role" >
                <p align="center" >
                    <img alt='Klik Untuk Hapus' border='0' src='${pageContext.request.contextPath}/images/user-edit-icon.png' 
                         onclick="popup('${pageContext.request.contextPath}/uam_register?showEditRole&idPengguna=${line.idPengguna}');"  onmouseover="this.style.cursor='pointer';">
                </p>
            </display:column>
            <display:column title="Delete" >
                <p align="center" >
                    <img alt='Klik Untuk Hapus' border='0' src='${pageContext.request.contextPath}/images/not_ok.gif' 
                         onclick="removePguna('${line.idPengguna}')" onmouseover="this.style.cursor='pointer';">
                </p>
            </display:column>
        </display:table>
    </div>

</s:form>

